#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    vector<int> findMissingAndRepeatedValues(vector<vector<int>>& grid)
    {
        vector<int> ans(2);
        int len = grid.size();
        vector<int> count(len * len + 1, 0);
        for (int i = 0; i < len; i++)
        {
            for (int j = 0; j < len; j++)
                count[grid[i][j]]++;
        }
        for (int i = 1; i < count.size(); i++)
        {
            if (count[i] == 2)
                ans[0] = i;
            if (count[i] == 0)
                ans[1] = i;
        }
        return ans;
    }
};